package com.xbang.attendance.utils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import sun.misc.Compare;

import edu.emory.mathcs.backport.java.util.Collections;


/**
 * @author huawei
 * @email alonelaval@gmail.com
 */
public class FieldUtil {
	//public static final Map<String, String> pofields = new HashMap<String, String>();
	//public static final Map<String,String> productFields =new HashMap<String, String>();
//	public static final Map<String,String> stockFields = new HashMap<String, String>();
	//public static final Map<String, String> deliveryFileds =new HashMap<String, String>();
	static{
//	//	pofields.put("id", "id");
//		pofields.put("orderNmber","订单单号");
//		pofields.put("number", "ASC编码");
//		pofields.put("name", "ASC简称");
//		pofields.put("productCode", "配件代码");
//		pofields.put("productName", "配件名称");
//		pofields.put("specification", "配件规格");
//		pofields.put("productNumber", "配件数量");
//		pofields.put("serviceAmount","运送服务商");
		
	//	productFields.put("id", "id");
//		productFields.put("categoryCode", "类别编码");
//		productFields.put("categoryName", "类别名称");
//		productFields.put("productCode", "产品编码");
//		productFields.put("productName", "产品名称");
//		productFields.put("specification", "产品规格");
//		productFields.put("material", "产品材质");
//		productFields.put("measureUnit", "计量单位");
		
	//	stockFields.put("id", "id");
//		stockFields.put("wareCode", "仓储编码");
//		stockFields.put("wareName", "仓储名称");
//		stockFields.put("proCode", "产品编码");
//		stockFields.put("proName","产品名称");
//		stockFields.put("cateCode", "类型编码");
//		stockFields.put("amount", "产品数量");
//		stockFields.put("specification", "产品规格");
//		stockFields.put("material", "产品材质");
//		stockFields.put("measureUnit", "计量单位");
//		stockFields.put("date", "入库日期");
	
//		deliveryFileds.put("doCode", "送货单单号");
//		deliveryFileds.put("wareName", "储运商");
//		deliveryFileds.put("stationCode", "ASC编码");
//		deliveryFileds.put("stationName", "ASC简称");
//		deliveryFileds.put("proCode", "配件代码");
//		deliveryFileds.put("proName", "配件名称");
//		deliveryFileds.put("specification", "配件规格");
//		deliveryFileds.put("productNumber", "配件数量");
		
	}
	
	public static class Filed{
		private Integer order;
		private String code;
		private String name;
		private Boolean isNumber =false;
		private Boolean isDate =false;
		
		public Filed(int order,String code,String name){
			this.order= order;
			this.code = code;
			this.name=name;
		}
		public Filed(int order,String code,String name,Boolean isNumber,Boolean isDate){
			this.order= order;
			this.code = code;
			this.name=name;
			this.isNumber =isNumber;
			this.isDate =isDate;
		}
		public Filed(int order,String code,String name,Boolean isDate){
			this.order= order;
			this.code = code;
			this.name=name;
			this.isDate =isDate;
		}
		
		public Boolean getIsNumber() {
			return isNumber;
		}
		public void setIsNumber(Boolean isNumber) {
			this.isNumber = isNumber;
		}
		public Boolean getIsDate() {
			return isDate;
		}
		public void setIsDate(Boolean isDate) {
			this.isDate = isDate;
		}
		public Filed(){
			
		}
		
		public Integer getOrder() {
			return order;
		}
		public void setOrder(Integer order) {
			this.order = order;
		}
		public String getCode() {
			return code;
		}
		public void setCode(String code) {
			this.code = code;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		
	}
	
	public static List<Filed> getPofields(){
		List<Filed> fields = new ArrayList<Filed>();
		fields.add(new FieldUtil.Filed(1,"orderNmber","订单号"));
		fields.add(new FieldUtil.Filed(2,"productCode", "配件代码"));
		fields.add(new FieldUtil.Filed(3,"number", "ASC代码"));
		fields.add(new FieldUtil.Filed(4,"name", "ASC名称"));
		fields.add(new FieldUtil.Filed(5,"is","是否已确认"));
		fields.add(new FieldUtil.Filed(6,"productNumber", "订购数量"));
		fields.add(new FieldUtil.Filed(7,"deliveryNumber","已确认数量"));
		
		fields.add(new FieldUtil.Filed(8,"orderDate","订单上报时间"));
		fields.add(new FieldUtil.Filed(9,"deliveryNumber","确认数量"));
		fields.add(new FieldUtil.Filed(10,"is","操作"));
		return Compare(fields);
	}
	
	public static List<Filed> getProductFields(){
		List<Filed> fields = new ArrayList<Filed>();
		fields.add(new FieldUtil.Filed(1,"categoryCode", "类别编码"));
		fields.add(new FieldUtil.Filed(2,"categoryName", "类别名称"));
		fields.add(new FieldUtil.Filed(3,"productCode", "产品编码"));
		fields.add(new FieldUtil.Filed(4,"productName", "产品名称"));
		fields.add(new FieldUtil.Filed(5,"specification", "产品规格"));
	//	fields.add(new FieldUtil.Filed(6,"material", "产品材质"));
	//	fields.add(new FieldUtil.Filed(7,"measureUnit", "计量单位"));
		return Compare(fields);
	}
	public static List<Filed> getStockFields(){
		
		List<Filed> fields = new ArrayList<Filed>();
		//fields.add(new FieldUtil.Filed(1,"wareCode", "仓储编码"));
		//fields.add(new FieldUtil.Filed(2,"wareName", "仓储名称"));
		fields.add(new FieldUtil.Filed(3,"proCode", "产品编码"));
		fields.add(new FieldUtil.Filed(4,"proName","产品名称"));
		//fields.add(new FieldUtil.Filed(5,"cateCode", "类型编码"));
	//	fields.add(new FieldUtil.Filed(6,"cateName", "类型名称"));
		fields.add(new FieldUtil.Filed(7,"outSum", "出库数量"));
		fields.add(new FieldUtil.Filed(8,"tureOutSum", "调拨数量"));
	//	fields.add(new FieldUtil.Filed(8,"material", "产品材质"));
		fields.add(new FieldUtil.Filed(9,"replenishmentSum", " 补货数量"));
		//fields.add(new FieldUtil.Filed(10,"date", "入库日期",true));
		return Compare(fields);
	}
	
public static List<Filed> getCompareFields(){
		
		List<Filed> fields = new ArrayList<Filed>();
		fields.add(new FieldUtil.Filed(1,"wareCode", "仓储编码"));
		fields.add(new FieldUtil.Filed(2,"wareName", "仓储名称"));
		fields.add(new FieldUtil.Filed(3,"proCode", "产品编码"));
		fields.add(new FieldUtil.Filed(4,"proName","产品名称"));
		//fields.add(new FieldUtil.Filed(5,"cateCode", "类型编码"));
	//	fields.add(new FieldUtil.Filed(6,"cateName", "类型名称"));
		fields.add(new FieldUtil.Filed(7,"outSum", "系统约定数量"));
		fields.add(new FieldUtil.Filed(8,"tureOutSum", "导入数量"));
	//	fields.add(new FieldUtil.Filed(8,"material", "产品材质"));
		fields.add(new FieldUtil.Filed(9,"replenishmentSum", "系统数量减导入数量"));
		//fields.add(new FieldUtil.Filed(10,"date", "入库日期",true));
		return Compare(fields);
	}
	public static List<Filed> getInventoryFields(){
		
		List<Filed> fields = new ArrayList<Filed>();
		fields.add(new FieldUtil.Filed(1,"wCode", "仓储编码"));
		fields.add(new FieldUtil.Filed(2,"wName", "仓储名称"));
		fields.add(new FieldUtil.Filed(3,"pCode", "产品编码"));
		fields.add(new FieldUtil.Filed(4,"pName","产品名称"));
		fields.add(new FieldUtil.Filed(5,"opDate", "日期",true));
		//fields.add(new FieldUtil.Filed(5,"cateCode", "类型编码"));
	//	fields.add(new FieldUtil.Filed(6,"cateName", 6"类型名称"));
		fields.add(new FieldUtil.Filed(7,"amount", "数量"));
		//fields.add(new FieldUtil.Filed(8, "数量"));
		//fields.add(new FieldUtil.Filed(8,"tureOutSum", "调拨数量"));
	//	fields.add(new FieldUtil.Filed(8,"material", "产品材质"));
		//fields.add(new FieldUtil.Filed(9,"replenishmentSum", " 补货数量"));
		//fields.add(new FieldUtil.Filed(10,"date", "入库日期",true));
		
		return Compare(fields);
	}
	
	public static List<Filed> getDeliveryFileds(){
		List<Filed> fields = new ArrayList<Filed>();
		//fields.add(new FieldUtil.Filed(1,"doCode", "送货单单号"));
		//fields.add(new FieldUtil.Filed(2,"wareName", "仓储名称"));
		//fields.add(new FieldUtil.Filed(3,"stationCode", "ASC编码"));
	//	fields.add(new FieldUtil.Filed(4,"stationName", "ASC简称"));
		fields.add(new FieldUtil.Filed(5,"pCode", "配件代码"));
		fields.add(new FieldUtil.Filed(6,"pName", "配件名称"));
		//fields.add(new FieldUtil.Filed(7,"specification", "产品规格"));
		fields.add(new FieldUtil.Filed(8,"amount", "配件数量"));
		return Compare(fields);
	}
	
	public static List<Filed> getExchangeFileds(){
		List<Filed> fields = new ArrayList<Filed>();
		fields.add(new FieldUtil.Filed(1,"wareCode", "仓储编码"));
		fields.add(new FieldUtil.Filed(2,"wareName", "仓储名称"));
		fields.add(new FieldUtil.Filed(3,"operation", "状态"));
		fields.add(new FieldUtil.Filed(5,"proCode", "配件代码"));
		fields.add(new FieldUtil.Filed(6,"proName", "配件名称"));
		fields.add(new FieldUtil.Filed(8,"amount", "数量"));
		fields.add(new FieldUtil.Filed(9,"opDate", "操作日期",true));
		return Compare(fields);
	}
	
	public static List<Filed> getStockOutLogFields(){
		
		List<Filed> fields = new ArrayList<Filed>();
		fields.add(new FieldUtil.Filed(1,"wareCode", "PO单号"));
		fields.add(new FieldUtil.Filed(1,"wareName", "Do单号"));
		fields.add(new FieldUtil.Filed(1,"wareCode", "仓储编码"));
		fields.add(new FieldUtil.Filed(2,"wareName", "仓储名称"));
		fields.add(new FieldUtil.Filed(3,"proCode", "产品编码"));
		fields.add(new FieldUtil.Filed(4,"proName","产品名称"));
		//fields.add(new FieldUtil.Filed(5,"cateCode", "类型编码"));
	//	fields.add(new FieldUtil.Filed(6,"cateName", "类型名称"));
		fields.add(new FieldUtil.Filed(5,"date", "出库日期",true));
		fields.add(new FieldUtil.Filed(7,"outSum", "缺货数量"));
//		fields.add(new FieldUtil.Filed(8,"tureOutSum", "调拨数量"));
//	//	fields.add(new FieldUtil.Filed(8,"material", "产品材质"));
//		fields.add(new FieldUtil.Filed(9,"replenishmentSum", " 补货数量"));
		//fields.add(new FieldUtil.Filed(10,"date", "入库日期",true));
		return Compare(fields);
	}
	
	public static List<Filed> Compare(List<Filed> fields){
		Collections.sort(fields,new Comparator<Filed>(){
			@Override
			public int compare(Filed o1, Filed o2) {
				return o1.getOrder().compareTo(o2.getOrder());
			}
		});
		return fields;
	}
	
	public static void main(String[] args) {
		for (Filed filed : getProductFields()) {
			System.out.println(filed.getOrder());
		}
	}
}

